<!DOCTYPE html>

<html lang="en" data-content_root="../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

  <title>FindOpenSSL &mdash; CMake 4.1.1 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=a2c47e09" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css?v=4d06bd55" />
    
    <script src="../_static/documentation_options.js?v=e6a937a4"></script>
    <script src="../_static/doctools.js?v=9bcbadda"></script>
    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
    
    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="FindOpenThreads" href="FindOpenThreads.html" />
    <link rel="prev" title="FindOpenSP" href="FindOpenSP.html" />
 

  </head><body>
    <input id="sidebar-check" type="checkbox" />
    <label id="sidebar-overlay" for="sidebar-check"></label>



    <div class="related relbar1" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="FindOpenThreads.html" title="FindOpenThreads"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="FindOpenSP.html" title="FindOpenSP"
             accesskey="P">previous</a> |</li>
  <li>
    <label class="sidebar-toggle" for="sidebar-check"></label>
  </li>
  <li class="rootlink">
    <img src="../_static/cmake-logo-16.png" width="16" height="16" alt=""/>
    <a href="https://cmake.org/">CMake 4.1.1</a>
    <span class="reldelim1"> &#187;</span>
  </li>
  <li>
    <a href="../index.html">Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" accesskey="U">cmake-modules(7)</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">FindOpenSSL</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="findopenssl">
<span id="module:FindOpenSSL"></span><h1>FindOpenSSL<a class="headerlink" href="#findopenssl" title="Link to this heading">¶</a></h1>
<p>Finds the installed OpenSSL encryption library and determines its version.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.20: </span>Support for specifying version range when calling the <span class="target" id="index-0-command:find_package"></span><a class="reference internal" href="../command/find_package.html#command:find_package" title="find_package"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">find_package()</span></code></a>
command.  When a version is requested, it can be specified as a single value
as before, and now also a version range can be used.  For a detailed
description of version range usage and capabilities, refer to the
<span class="target" id="index-1-command:find_package"></span><a class="reference internal" href="../command/find_package.html#command:find_package" title="find_package"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">find_package()</span></code></a> command.</p>
</div>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.18: </span>Support for OpenSSL 3.0.</p>
</div>
<section id="components">
<h2>Components<a class="headerlink" href="#components" title="Link to this heading">¶</a></h2>
<p>This module supports the following optional components:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">Crypto</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.12.</span></p>
</div>
<p>Ensures that the OpenSSL <code class="docutils literal notranslate"><span class="pre">crypto</span></code> library is found.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">SSL</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.12.</span></p>
</div>
<p>Ensures that the OpenSSL <code class="docutils literal notranslate"><span class="pre">ssl</span></code> library is found.</p>
</dd>
</dl>
<p>Components can be optionally specified using a standard syntax:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">find_package(</span><span class="nb">OpenSSL</span><span class="w"> </span><span class="p">[</span><span class="no">COMPONENTS</span><span class="w"> </span><span class="nv">&lt;components&gt;...</span><span class="p">]</span><span class="nf">)</span>
</pre></div>
</div>
<p>If no components are requested, module by default searches for the <code class="docutils literal notranslate"><span class="pre">Crypto</span></code>
as required and <code class="docutils literal notranslate"><span class="pre">SSL</span></code> as optional component.</p>
</section>
<section id="imported-targets">
<h2>Imported Targets<a class="headerlink" href="#imported-targets" title="Link to this heading">¶</a></h2>
<p>This module provides the following <a class="reference internal" href="../manual/cmake-buildsystem.7.html#imported-targets"><span class="std std-ref">Imported Targets</span></a>:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">OpenSSL::Crypto</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.4.</span></p>
</div>
<p>Target encapsulating the OpenSSL <code class="docutils literal notranslate"><span class="pre">crypto</span></code> library usage requirements,
available only if the <code class="docutils literal notranslate"><span class="pre">crypto</span></code> library is found.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenSSL::SSL</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.4.</span></p>
</div>
<p>Target encapsulating the OpenSSL <code class="docutils literal notranslate"><span class="pre">ssl</span></code> library usage requirements, available
only if the <code class="docutils literal notranslate"><span class="pre">ssl</span></code> library is found.  For convenience, this target also links
<code class="docutils literal notranslate"><span class="pre">OpenSSL::Crypto</span></code>, since the <code class="docutils literal notranslate"><span class="pre">ssl</span></code> library depends on the <code class="docutils literal notranslate"><span class="pre">crypto</span></code>
library.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenSSL::applink</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.18.</span></p>
</div>
<p>Target encapsulating the OpenSSL application-side interface
(<code class="docutils literal notranslate"><span class="pre">openssl/applink.c</span></code>) usage requirements, available only if OpenSSL is found
and its version is at least 0.9.8.</p>
<p>This interface provides a glue between OpenSSL BIO layer and the Windows
compiler runtime environment and may need to be compiled into projects when
using MSVC.  By linking this target, the other OpenSSL imported targets can be
linked even if the project uses different MSVC runtime configuration.  Linking
this target on platforms other than MSVC has no effect.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The interface file is added using the <span class="target" id="index-0-prop_tgt:INTERFACE_SOURCES"></span><a class="reference internal" href="../prop_tgt/INTERFACE_SOURCES.html#prop_tgt:INTERFACE_SOURCES" title="INTERFACE_SOURCES"><code class="xref cmake cmake-prop_tgt docutils literal notranslate"><span class="pre">INTERFACE_SOURCES</span></code></a> target
property.  Due to how interface sources are propagated in CMake, it is
recommended to link the <code class="docutils literal notranslate"><span class="pre">OpenSSL::applink</span></code> target as
<a class="reference internal" href="../manual/cmake-buildsystem.7.html#target-command-scope"><span class="std std-ref">PRIVATE</span></a> to ensure that it is linked only once
in the entire dependency graph of any library or executable:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">target_link_libraries(</span><span class="nb">project_target</span><span class="w"> </span><span class="no">PRIVATE</span><span class="w"> </span><span class="nb">OpenSSL</span><span class="o">::</span><span class="nb">applink</span><span class="nf">)</span>
</pre></div>
</div>
<p>Using other scopes for this target specifically can lead to unexpected
issues during the build or link process, as both the ISO C and ISO C++
standards place very few requirements on how linking should behave.</p>
</div>
</dd>
</dl>
</section>
<section id="result-variables">
<h2>Result Variables<a class="headerlink" href="#result-variables" title="Link to this heading">¶</a></h2>
<p>This module defines the following variables:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">OpenSSL_FOUND</span></code></dt><dd><p>Boolean indicating whether the OpenSSL library has been found.  For backward
compatibility, the <code class="docutils literal notranslate"><span class="pre">OPENSSL_FOUND</span></code> variable is also set to the same value.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_INCLUDE_DIR</span></code></dt><dd><p>The OpenSSL include directory.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_CRYPTO_LIBRARY</span></code></dt><dd><p>The OpenSSL <code class="docutils literal notranslate"><span class="pre">crypto</span></code> library.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_CRYPTO_LIBRARIES</span></code></dt><dd><p>The OpenSSL <code class="docutils literal notranslate"><span class="pre">crypto</span></code> library and its dependencies.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_SSL_LIBRARY</span></code></dt><dd><p>The OpenSSL <code class="docutils literal notranslate"><span class="pre">ssl</span></code> library.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_SSL_LIBRARIES</span></code></dt><dd><p>The OpenSSL <code class="docutils literal notranslate"><span class="pre">ssl</span></code> library and its dependencies.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_LIBRARIES</span></code></dt><dd><p>All OpenSSL libraries and their dependencies.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_VERSION</span></code></dt><dd><p>The OpenSSL version found.  This is set to
<code class="docutils literal notranslate"><span class="pre">&lt;major&gt;.&lt;minor&gt;.&lt;revision&gt;&lt;patch&gt;</span></code> (e.g. <code class="docutils literal notranslate"><span class="pre">0.9.8s</span></code>).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_APPLINK_SOURCE</span></code></dt><dd><p>The sources in the target <code class="docutils literal notranslate"><span class="pre">OpenSSL::applink</span></code> mentioned above.  This variable
is only defined if found OpenSSL version is at least 0.9.8 and the platform is
MSVC.</p>
</dd>
</dl>
</section>
<section id="hints">
<h2>Hints<a class="headerlink" href="#hints" title="Link to this heading">¶</a></h2>
<p>This module accepts the following variables to control the search behavior:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_ROOT_DIR</span></code></dt><dd><p>Set to the root directory of an OpenSSL installation to search for the OpenSSL
libraries in custom locations.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_USE_STATIC_LIBS</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.4.</span></p>
</div>
<p>Set to <code class="docutils literal notranslate"><span class="pre">TRUE</span></code> to prefer static OpenSSL libraries over shared ones.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_MSVC_STATIC_RT</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.5.</span></p>
</div>
<p>Set to <code class="docutils literal notranslate"><span class="pre">TRUE</span></code> to search for the OpenSSL libraries built with the MSVC static
runtime (MT).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">ENV{PKG_CONFIG_PATH}</span></code></dt><dd><p>On UNIX-like systems, <code class="docutils literal notranslate"><span class="pre">pkg-config</span></code> is used to locate OpenSSL.  Set the
<code class="docutils literal notranslate"><span class="pre">PKG_CONFIG_PATH</span></code> environment variable to specify alternate locations, which
is useful on systems with multiple library installations.</p>
</dd>
</dl>
</section>
<section id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Link to this heading">¶</a></h2>
<p>Finding the OpenSSL <code class="docutils literal notranslate"><span class="pre">crypto</span></code> library and linking it to a project target:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">find_package(</span><span class="nb">OpenSSL</span><span class="nf">)</span>
<span class="nf">target_link_libraries(</span><span class="nb">project_target</span><span class="w"> </span><span class="no">PRIVATE</span><span class="w"> </span><span class="nb">OpenSSL</span><span class="o">::</span><span class="nb">Crypto</span><span class="nf">)</span>
</pre></div>
</div>
<p>The following example shows how to find the OpenSSL <code class="docutils literal notranslate"><span class="pre">crypto</span></code> and <code class="docutils literal notranslate"><span class="pre">ssl</span></code>
libraries and link them to a project target.  The <code class="docutils literal notranslate"><span class="pre">SSL</span></code> component is
explicitly specified to ensure that the find module reports an error if the
<code class="docutils literal notranslate"><span class="pre">ssl</span></code> library is not found:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">find_package(</span><span class="nb">OpenSSL</span><span class="w"> </span><span class="no">COMPONENTS</span><span class="w"> </span><span class="no">SSL</span><span class="nf">)</span>
<span class="nf">target_link_libraries(</span><span class="nb">project_target</span><span class="w"> </span><span class="no">PRIVATE</span><span class="w"> </span><span class="nb">OpenSSL</span><span class="o">::</span><span class="no">SSL</span><span class="nf">)</span>
</pre></div>
</div>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper">
  <div>
    <h3>Table of Contents</h3>
    <ul>
<li><a class="reference internal" href="#">FindOpenSSL</a><ul>
<li><a class="reference internal" href="#components">Components</a></li>
<li><a class="reference internal" href="#imported-targets">Imported Targets</a></li>
<li><a class="reference internal" href="#result-variables">Result Variables</a></li>
<li><a class="reference internal" href="#hints">Hints</a></li>
<li><a class="reference internal" href="#examples">Examples</a></li>
</ul>
</li>
</ul>

  </div>
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="FindOpenSP.html"
                          title="previous chapter">FindOpenSP</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="FindOpenThreads.html"
                          title="next chapter">FindOpenThreads</a></p>
  </div>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/module/FindOpenSSL.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="FindOpenThreads.html" title="FindOpenThreads"
             >next</a> |</li>
        <li class="right" >
          <a href="FindOpenSP.html" title="FindOpenSP"
             >previous</a> |</li>
  <li>
    <label class="sidebar-toggle" for="sidebar-check"></label>
  </li>
  <li class="rootlink">
    <img src="../_static/cmake-logo-16.png" width="16" height="16" alt=""/>
    <a href="https://cmake.org/">CMake 4.1.1</a>
    <span class="reldelim1"> &#187;</span>
  </li>
  <li>
    <a href="../index.html">Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" >cmake-modules(7)</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">FindOpenSSL</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
    &#169; Copyright 2000-2025 Kitware, Inc. and Contributors.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3.
    </div>
<script type="text/javascript">
(function() {
  "use strict";
  const hide = () => document.getElementById("sidebar-check").checked = false;
  addEventListener("keydown", e => (e.key === "Escape") && hide());
  addEventListener("click", e => (e.target.tagName === "A") && hide());
  addEventListener("hashchange", hide)
})();
</script>
  </body>
</html>